﻿@using Citi.GocAttributes.WebUI.Models
@model Webdiyer.WebControls.Mvc.PagedList<Citi.GocAttributes.Domain.Goc>
@{
    ViewBag.Title = "GOC Exceptions";
}
@section Menu
{
    @Html.Partial("~/Views/Menu/Gocs.cshtml")
}
<script type="text/javascript">
    function applyIndividualRule(gocId) {
        $("#applyRule" + gocId).attr('checked', true);

        $("#ruleOpenForm").click();
    }

    function openCloseRuleDialog() {
        if ($("input:checkbox[class=gocCheck]:checked").length == 0) {
            alert("No GOC was selected. Select at least one GOC to apply a rule.");
            return;
        }

        $('#applyRuleExceptionModal').modal('toggle');
        $('#buttonApplyRule').unbind("click");

        $('#buttonApplyRule').click(function () {
            var gocsId = '';

            $("input:checkbox[class=gocCheck]:checked").each(function (index, item) {
                gocsId += item.id.replace('applyRule', '') + '|';
            });

            $("#GocsId").val(gocsId);
            $("#ruleIdException").val($("#RuleId").val());

            $('#submitRuleForm').click();

            window.location = '@Url.Action("Exceptions")';
        });
    }
</script>
<h2>
    GOC Exceptions</h2>
<div id="filter">
    @Html.Partial("~/Views/Goc/Filter.cshtml", new GocFilterModel { Exception = true })
</div>
@Ajax.ActionLink("Apply Rule", "ApplyRule", "Goc", new AjaxOptions { UpdateTargetId = "filterApplyRule", OnBegin = "openCloseRuleDialog" },
    new { @class = "btn", id = "ruleOpenForm" })
<br />
<br />
<div id="gocsList">
    @Html.Partial("~/Views/Goc/List.cshtml", new GocOptionModel { Exception = true, Gocs = Model })
</div>
<div id="applyRuleExceptionModal" class="modal hide" style="width: 650px; margin-left: -300px;">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">
            ×</button>
    </div>
    <div class="modal-body" id="filterApplyRule">
    </div>
    <div class="modal-footer">
        <a href="#" class="btn btn-primary" id="buttonApplyRule">Apply</a> <a href="#" class="btn"
            data-dismiss="modal">Cancel</a>
    </div>
</div>
